<?php


namespace app\admin\model;


use think\Model;

class Store extends Model
{
    protected $autoWriteTimestamp = true;

    /**
     * @param $id
     * @param $url
     * @param $title
     * @param $img
     * @param $address
     * @param $industry
     * @param $cost
     * @param $pv
     * @param $rent
     * @return bool
     */
    public static function addSto($data)
    {
        $id = $data["id"];
        $url = $data["url"];
        $title = $data["title"];
        $img = $data["img"];
        $address = $data["address"];
        $industry = $data["industry"];
        $cost = $data["cost"];
        $pv = $data["pv"];
        $rent = $data["rent"];

        $s = new Store();
        $res = $s->where("store_id",$id)->find();
        if(!$res){
            $s["store_id"] = $id;
            $s["url"] = $url;
            $s["title"] = $title;
            $s["img"] = $img;
            $s["address"] = $address;
            $s["industry"] = $industry;
            $s["cost"] = $cost;
            $s["pv"] = $pv;
            $s["rent"] = $rent;
            $re = $s->save();
            if (!$re){
                return false;
            }
        }else{
            $res["store_id"] = $id;;
            $res["url"] = $url;
            $res["title"] = $title;
            $res["img"] = $img;
            $res["address"] = $address;
            $res["industry"] = $industry;
            $res["cost"] = $cost;
            $res["pv"] = $pv;
            $res["rent"] = $rent;
            $re = $res->save();
            if (!$re){
                return false;
            }
        }
        return $data;
    }
}